<template>
	<view class="opinonPage">
		<view class="uni-textarea">
			<view class="uni-textarea"><textarea v-model="opinion" class="comment-input" placeholder="请输入反馈意见" /></view>
		</view>
		<view class="comment-btn" @tap="submitOpinion()"><text>提问</text></view>
	</view>
</template>

<script>
import api from '@/common/lib/request.js';
export default {
	data() {
		return {
			opinion: ''
		};
	},
	methods: {
		submitOpinion() {
			let _this = this;
			if (!_this.opinion.trim()) {
				uni.showToast({
					title: '尚未输入反馈意见',
					icon: 'none'
				});
				return;
			}
			api.request({
				url: '/feedback',
				data: {
					content: _this.opinion
				}
			})
				.then(response => {
					uni.showToast({
						title: '提交成功',
						icon: 'none'
					});
					uni.navigateBack({
						delta: 1
					});
				})
				.catch(err => {
					uni.showToast({
						title: err,
						icon: 'none'
					});
				});
		}
	}
};
</script>

<style>
.opinonPage {
	padding: 40upx 30upx;
}
.comment-input {
	border: 1px solid #dcdfe6;
	height: 360upx;
	border-radius: 12upx;
	font-size: 32upx;
}

.comment-btn {
	float: right;
	margin-top: 20upx;
	width: 160upx;
	height: 72upx;
	border-radius: 36upx;
	background-color: orange;
	color: white;
	display: flex;
	align-items: center;
	justify-content: center;
}
</style>
